package com.hotelManagerSystem.mapper;

import com.hotelManagerSystem.model.CleaningRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Cynthia
 * @since 2021-12-22
 */
public interface CleaningRecordMapper extends BaseMapper<CleaningRecord> {

    @Select("select * from cleaning_record where cleaning_state=#{cleaningState}")
    List<CleaningRecord> queryInfoByState(int cleaningState);

    @Update("update cleaning_record set cleaning_state=0,staff_id=#{staffId} where cleaning_record_id=#{cleaningRecordId}")
    int updateRecordById(int cleaningRecordId, int staffId);

    @Select("select * from cleaning_record where staff_id=#{staffId}")
    List<CleaningRecord> queryInfoByStaffId(int staffId);

    @Select("select * from cleaning_record where staff_id=#{staffId} and cleaning_state=#{cleaningState}")
    List<CleaningRecord> queryInfoByStaffIdAndState(int staffId, Integer cleaningState);

    @Update("update cleaning_record set cleaning_state=1,clean_over_time=#{cleanOverTime} where cleaning_record_id=#{cleaningRecordId}")
    int updateRecordState(@Param("cleaningRecordId")int cleaningRecordId, @Param("cleanOverTime")String cleanOverTime);

    @Select("select * from cleaning_record")
    List<CleaningRecord> queryAll();

    @Insert("insert into cleaning_record values(null,#{recordTime},null,-1,#{roomId},null)")
    int insertOne(@Param("roomId")Integer roomId, @Param("recordTime")String recordTime);
}
